/*--------------------------------------------------------------------------
    This source file is part of Abraxas Game Engine
    For the latest info, see http://code.google.com/abraxasge/
    Copyright (C) 2009, Andrew LeRoy <aleroy@member.igda.org>
    ---

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA  02110-1301, USA.
--------------------------------------------------------------------------*/
#ifndef _Abx_Options_hpp_
#define _Abx_Options_hpp_

#include "AbxPrerequisites.hpp"
#include "AbxLongevity.hpp"
#include "loki/Singleton.h"

#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>

namespace Abx
{
    class _AbxExport OptionsImpl
    {
      public:
        OptionsImpl();
        ~OptionsImpl();
        
        bool startup(std::vector<String> args);
        bool shutdown();
        bool empty(String const& name);
        
        /**
         * Returns a value of type R for the option specified by name
         * @code
         *  // EXAMPLES:
         *  String stringValue = getOption<String>("StringOption");
         *  // ... or ... //
         *  std::vector<String> stringVectorValue = getOption<std::vector<String> >("StringVectorOption");
         * @endcode
         */
        template <typename R>
        R getOption(String const& name)
        {
            R value = values_[name].as<R>();
            return value;
        }

      private:
        static String const sDEFAULT_CONFIG_FILE;
        
        boost::program_options::options_description options_;
        boost::program_options::variables_map       values_;
    };
    
    inline uint32 GetLongevity(OptionsImpl*) { return SLT_OPTIONS; };
    
    typedef Loki::SingletonHolder< OptionsImpl,
                                   Loki::CreateUsingNew,
                                   Loki::SingletonWithLongevity
                                 > Options;
} // namespace Abx

#endif // _Abx_Options_hpp_
